﻿using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.Abp.Domain.Entities;

namespace Framework.SqlSugarCore.Abstractions
{
	/// <summary>
	/// 框架实体基类Id
	/// </summary>
	public abstract class EntityBaseId : IEntity<long>
	{
		/// <summary>
		/// 雪花Id
		/// </summary>
		[SugarColumn(ColumnName = "Id", ColumnDescription = "主键Id", IsPrimaryKey = true, IsIdentity = false)]
		public long Id { get; set; }

		public object?[] GetKeys()
		{
			return [Id];
		}
	}

	/// <summary>
	/// 框架实体基类
	/// </summary>
	public abstract class EntityBase : EntityBaseId, IDeletedFilter
	{
		/// <summary>
		/// 创建时间
		/// </summary>
		[SugarColumn(ColumnDescription = "创建时间", IsOnlyIgnoreUpdate = true)]
		public virtual DateTime? CreateTime { get; set; }

		/// <summary>
		/// 更新时间
		/// </summary>
		[SugarColumn(ColumnDescription = "更新时间", IsOnlyIgnoreInsert = true)]
		public virtual DateTime? UpdateTime { get; set; }

		/// <summary>
		/// 创建者Id
		/// </summary>
		[SugarColumn(ColumnDescription = "创建者Id", IsOnlyIgnoreUpdate = true)]
		public virtual long? CreateUserId { get; set; }

		/// <summary>
		/// 修改者Id
		/// </summary>
		[SugarColumn(ColumnDescription = "修改者Id", IsOnlyIgnoreInsert = true)]
		public virtual long? UpdateUserId { get; set; }

		/// <summary>
		/// 软删除
		/// </summary>
		[SugarColumn(ColumnDescription = "软删除")]
		public virtual bool IsDelete { get; set; } = false;
	}

	/// <summary>
	/// 租户基类实体
	/// </summary>
	public abstract class EntityTenant : EntityBase, ITenantIdFilter
	{
		/// <summary>
		/// 租户Id
		/// </summary>
		[SugarColumn(ColumnDescription = "租户Id", IsOnlyIgnoreUpdate = true)]
		public virtual long? TenantId { get; set; }
	}

	/// <summary>
	/// 租户基类实体Id
	/// </summary>
	public abstract class EntityTenantId : EntityBaseId, ITenantIdFilter
	{
		/// <summary>
		/// 租户Id
		/// </summary>
		[SugarColumn(ColumnDescription = "租户Id", IsOnlyIgnoreUpdate = true)]
		public virtual long? TenantId { get; set; }
	}
}
